package com.seecen.controller;

import com.seecen.pojo.entity.Contract;
import com.seecen.service.ContractService;
import com.seecen.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * FIND YOUR PURPOSE
 *
 * @author: CYZ
 * @date: 2025/10/20/12:26
 * @description:
 */
@Slf4j
@RestController
@RequestMapping("/api")
@CrossOrigin
public class ContractController {

    @Autowired
    private ContractService contractService;

    /**
     * 查询电子合同
     * @param contractNo 电子合同统一编号
     * @return 合同信息
     */
    @PostMapping("/contract")
    public Result getContractByNo(@RequestParam("contractNo") String contractNo) {
        log.info("查询电子合同，合同编号：{}", contractNo);

        Contract contract = contractService.getContractByNo(contractNo);
        if (contract == null) {
            return Result.build(null, com.seecen.utils.ResultCode.DATA_NOT_FOUND);
        }

        return Result.ok(contract);
    }
}